package com.huawei;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created by Z-hong on 2024/7/19.
 */

public class HJ50_hard {
    static Map<Character,Character> map=new HashMap<>();
    static {
        map.put('}','{');
        map.put(')','(');
        map.put(']','[');
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        Stack<String> number =new Stack<>();
        Stack<Character> symbol =new Stack<>();
        char[] charArray = str.toCharArray();
        //中缀转后缀表达式
        for (int i = 0; i < str.length(); i++) {
            StringBuffer sb=new StringBuffer();
            //判断是否为数字
            if(Character.isDigit(charArray[i])){
                sb.append(charArray[i]);
                while(++i<str.length()&&Character.isDigit(charArray[i])){
                    sb.append(charArray[i]);
                }
                number.push(sb.toString());
                i--;

            }
            //判断是否为-
            else if (charArray[i]=='-'){
                //如果-代表的是符号 则不需要添加-
                Boolean flag=!((i==0)||i-1>=0&&(charArray[i-1]=='('||charArray[i-1]=='{'||charArray[i-1]=='['));
                sb.append(charArray[i]);
                //代表的是负数
                if(Character.isDigit(charArray[i+1])){
                    while(++i<str.length()&&Character.isDigit(charArray[i])){
                        sb.append(charArray[i]);
                    }
                    i--;
                    if(symbol.size()!=0){
                        char peek = symbol.peek();
                        if(getBig(peek)>=getBig('+')){
                            String c=number.pop();
                            String b=number.pop();
                            number.push(String.valueOf(getNum(peek,b,c)));
                            symbol.pop();
                        }

                    }
                    number.push(sb.toString());
                    if(flag){
                        symbol.push('+');
                    }
                }
                //代表的是符号
                else{
                    if(symbol.size()!=0){
                        char peek = symbol.peek();
                        if(getBig(peek)>=getBig('-')){
                            String c=number.pop();
                            String b=number.pop();
                            number.push(String.valueOf(getNum(peek,b,c)));
                            symbol.pop();
                        }
                    }
                    symbol.push('-');
                }


            }else if(charArray[i]=='+'||charArray[i]=='*'||charArray[i]=='/'){
                if(symbol.isEmpty()){
                    symbol.push(charArray[i]);
                    continue;
                }
                char peek = symbol.peek();
                if(getBig(peek)>=getBig(charArray[i])){
                    String c=number.pop();
                    String b=number.pop();
                    number.push(String.valueOf(getNum(peek,b,c)));
                    symbol.pop();
                }
                symbol.push(charArray[i]);

            }else if(charArray[i]=='('||charArray[i]=='{'||charArray[i]=='['){
                symbol.push(charArray[i]);
            }else if(charArray[i]==')'||charArray[i]=='}'||charArray[i]==']'){
                char a=symbol.pop();
                while(a!=map.get(charArray[i])){
                    String c=number.pop();
                    String b=number.pop();
                    number.push(String.valueOf(getNum(a,b,c)));
                    a=symbol.pop();
                }
            }

        }

        while(!symbol.isEmpty()){
            String c=number.pop();
            String b=number.pop();
            number.push(String.valueOf(getNum(symbol.pop(),b,c)));
        }
        System.out.println(number.pop());

    }

    //得到运算符大小
    public static int getBig(char a){
        if(a == '/'||a=='*'){return 2;}
        else if(a=='+'||a=='-'){return 1;}
        return 0;
    }

    //算数
    public static int getNum(char a,String b,String c){
        int num_1=Integer.parseInt(String.valueOf(b));
        int num_2=Integer.parseInt(String.valueOf(c));
        switch (a){
            case '+':
                return num_1+num_2;
            case '-':
                return num_1-num_2;
            case '*':
                return num_1*num_2;
            case '/':
                return num_1/num_2;
            default:
                return 0;
        }
    }
}
